﻿#ifndef TIANYU_CLIENT_SLOT_
#define TIANYU_CLIENT_SLOT_

#include <atomic>
#include "client_msg.h"
#include "server_msg.h"
#include "SyncQueue.h"

class CClientSlot
{
private:
	void stopThread(void); 

protected:
	std::shared_ptr<std::thread>	m_thread;
	std::string						m_threadId;
	SyncQueue<CClientSocketMsg>		m_queue_socket;
	SyncQueue<CProxySocketMsg>		m_queue_server_socket;
	std::atomic_bool				m_running;		//	停止标志
	std::once_flag					m_flag;

protected:
	CClientSlot(uint32_t maxTaskCount = 8192);


public:
	virtual ~CClientSlot(void);
	virtual void RunThread(void) = 0;
	virtual void ProcessClientMsg(CClientSocketMsg& val) = 0;
	virtual void ProcessServerMsg(CProxySocketMsg& val) = 0;

public:
	void Start(void);
	void Stop(void);

	void AddClientMsgPtr(CClientSocketMsg& val);
	void AddServerMsgPtr(CProxySocketMsg& val);
};

#endif 